# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=freetype
pkgver=2.13.2
pkgrel=0
pkgdesc="TrueType font rendering library"
url="https://www.freetype.org/"
arch="all"
license="FTL OR GPL-2.0-or-later"
options="!check"
makedepends="
	brotli-dev
	bzip2-dev
	libpng-dev
	libx11-dev
	meson
	zlib-dev
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-demos
	$pkgname-doc
	"
source="
	https://de.freedif.org/savannah/freetype/freetype-$pkgver.tar.xz
	https://de.freedif.org/savannah/freetype/ft2demos-$pkgver.tar.xz
	pcf-family-names.patch
	subpixel.patch
	table-validation-modules.patch
	"

# secfixes:
#   2.12.1-r0:
#     - CVE-2022-27404
#     - CVE-2022-27405
#     - CVE-2022-27406
#   2.10.4-r0:
#     - CVE-2020-15999
#   2.9-r1:
#     - CVE-2018-6942
#   2.7.1-r1:
#     - CVE-2017-8105
#     - CVE-2017-8287

prepare() {
	default_prepare

	ln -sfv ../../freetype-$pkgver "$srcdir"/ft2demos-$pkgver/subprojects/freetype2
}

build() {
	abuild-meson \
		-Dfreetype2:default_library=both \
		-Dlibrsvg=disabled \
		"$srcdir"/ft2demos-$pkgver output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	install -Dm644 builds/unix/freetype2.m4 \
		-t "$pkgdir"/usr/share/aclocal
}

demos() {
	pkgdesc="A collection of FreeType demos"

	amove usr/bin
}

sha512sums="
a5917edaa45cb9f75786f8a4f9d12fdf07529247e09dfdb6c0cf7feb08f7588bb24f7b5b11425fb47f8fd62fcb426e731c944658f6d5a59ce4458ad5b0a50194  freetype-2.13.2.tar.xz
aa83ba4212ff7c4453b72f036136cb9b04cacf7d196388a3e4752613e000b3bb45a4dcf63d3d1d5b3d6ada10720304b532fb6e33ed6a5b399dcce45c27af9ade  ft2demos-2.13.2.tar.xz
78ad6b1de388d3986fd5a51a7076b0a9d782733e85f400fc8c070b40e5e48130a562a67a7a9b251169b74ae052f571ea8e6b0f9435c271520d93dd72c1845d59  pcf-family-names.patch
55fb06dbc7cc950129a99d9fd5480397b3e0720f32ab65fb3893768ed40e2de27be2cfd52ec6da490f79c79b4ddfecd0b7efcd32da4a95f2666a6b67a3cd9a31  subpixel.patch
580fe59acddfd41966e387bdb6a88336b8bc119cc3d60d8689be20c96fb0dd07c5138ea31f6cb9c854f497ecb41c3adc49eb3ec16a34b2e010e8294851770763  table-validation-modules.patch
"
